package com.qyhl.webtv.module_circle.common;

import android.util.Log;

import com.qyhl.webtv.basiclib.utils.DESedeUtil;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.circle.CircleMessageBean;
import com.qyhl.webtv.commonlib.service.CircleService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 圈子工具类
 * @author helin
 * @date 2019年4月22日11:02:06
 */
public class CircleUtils {

    /**
     * 图片保存文件夹
     */
    public static final String PIC = CommonUtils.getInstance().getCachePath()+ "/picture";



    public  static  void getCircleMessage( CircleService.CircleMessageCallBack circleMessageCallBack ){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String time = sdf.format(new Date());
        String code = "Z5" + time + "I2863";
        String url = CircleUrl.CIRCLE_URL + "?timestamp=" + time;
            String userName = CommonUtils.getInstance().getUserName();

        EasyHttp.post(url)
                .upBytes(DESedeUtil.encryptMode(code, "siteId=" + CommonUtils.getInstance().getSite() + "&method=messageNotice" + "&username=" + userName
                ))
                .isDecrypt(true)
                .decryptKet(code)
                .execute(new SimpleCallBack<CircleMessageBean>() {
                    @Override
                    public void onError(ApiException e) {
                        circleMessageCallBack.onError();
                    }

                    @Override
                    public void onSuccess(CircleMessageBean circleMessageBean) {
                        circleMessageCallBack.onSuccess(circleMessageBean);
                    }
                });

    }

    /**
     * 积分错误码
     *
     * @param code 错误码
     * @return 错误信息
     */
    public static String getScoreMessage(int code) {
        switch (code) {
            case 1:
                return "请求出错！";
            case 2:
                return "code:2,请求出错！";
            case 3:
                return "请求失败，参数异常！";
            case 4:
                return "请求失败，地址不存在！";
            case 5:
                return "code:5,请求出错！";
            case 11:
                return "操作异常！";
            case 12:
                return "今天已经签到！";
            case 13:
                return "金币达到上限！";
            case 14:
                return "行为不存在！";
            case 15:
                return "用户不存在！";
            case 21:
                return "金币不足！";
            case 22:
                return "金币太少！";
            case 31:
                return "未绑定支付宝账号！";
            case 32:
                return "未绑定微信账号！";
            case 33:
                return "提现余额不足！";
            case 34:
                return "提现手续费不足！";
            case 35:
                return "提现金额不在范围内！";
            case 36:
                return "未知的支付平台！";
            default:
                return "请求出错！";
        }
    }


    /**
     * 圈子
     *
     * @param code
     * @return
     */
    public static String getCircleMessage(int code) {
        Log.i("2@",code+"");
        String msg = "";
        switch (code) {
            case 200:
                break;
            case 1://请求失败
                msg = "请求失败，请稍后再试！";
                break;
            case 11://没有时间戳
                msg = "请求失败，请稍后再试！";
                break;
            case 12://请求超时
                msg = "请求超时，请稍后再试！";
                break;
            case 13://加密错误
                msg = "请求失败，请稍后再试！";
                break;
            case 99://文字包含敏感字
                msg = "文字包含敏感字或无意义内容！";
                break;
            case 101://已关注，无法重复关注
                msg = "已关注，无法重复关注";
                break;
            case 102://未关注，无法取消关注
                msg = "未关注，无法取消关注";
                break;
            case 103://已屏蔽，无法再次屏蔽
                msg = "已屏蔽，无法再次屏蔽";
                break;
            case 104://未屏蔽，无法取消屏蔽
                msg = "未屏蔽，无法取消屏蔽";
                break;
            case 111://已喜欢，无法再次喜欢
                msg = "已喜欢，无法再次喜欢";
                break;
            case 112://未喜欢，无法取消喜欢
                msg = "未喜欢，无法取消喜欢";
                break;
            case 113://主题不存在
                msg = "该主题不存在！";
                break;
            case 121://评论不存在
                msg = "该评论不存在！";
                break;
            case 131://无效的主题类型
                msg = "无效的主题类型";
                break;
            case 132://标签无效
                msg = "标签无效";
                break;
            case 133://站点不存在
                msg = "站点不存在";
                break;
            case 141://内容过少
                msg = "内容过少";
                break;
            case 151://对方已拉黑你
                msg = "对方已拉黑你";
                break;
            case 155://您被禁言了
                msg = "您被禁言了";
                break;
            case 161://无效的举报
                msg = "无效的举报";
                break;
            case 171://无法删除
                msg = "无法删除";
                break;
            default:
                msg = "请求失败，请稍后再试！";
                break;
        }
        return msg;
    }

}
